Hugi Magazine #33: MP3 Power

Hugi #33 header graphic

Faery Tale Save Game Editor (PureBasic) (By Fable Fox)

Faery Tale

A stolen computer causes a lot of things to go haywire. Worry not, I'll keep on fighting anyway. In last HUGI (#32) I taught you how to hack into save games, right? Well, now I want to put a Pure Basic tutorial into the mix. What do we get? How to write a save game editor using Pure Basic, that's what :-)

Graphical User Interface

First, I want to congratulate FarbRausch for a small demo well done (Debris). OK, return to the topic. Pure Basic has a GUI editor, use it to design a GUI for your save game application. You must know what you want to read and edit / change. Look at the picture below to get some idea on designing a save game editor for Faery Tale.

Run it, you will receive a working application like this.

Call FileRequester so our application looks professional. Example from the code is given below.

StandardFile$ = "C:\dosbox65\faery\a.fae" ; set initial file+path to display
Pattern$ = "Faery Tale Save (*.fae)|*.fae;|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
File$ = OpenFileRequester("Please choose file to load", StandardFile$, Pattern$, Pattern)
If File$
LoadSaveGame(File$)
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf 

Now set the text box based on all the value we have read. To read the data, you can use the functions FileSeek() and ReadByte(). To set the textbox value, use SetGadgetText().

; bravery
FileSeek(0,170)
brave = ReadByte(0)
SetGadgetText(#String_bra,Str(brave)) 

Change it to the value we want - under 255 though (1 byte). So now we must read the value from the text box and save it to our file. To get the value and change it from text into integer, we can use GetGadgetText() and Val(). To write it to the file we use WriteByte().

; bravery
FileSeek(0,170)
brave = Val(GetGadgetText(#String_bra))
WriteByte(0,brave) 

Why don't you read the file back after saving to it? Ah..... a hacked save game :-) Now do the same to all item like keys, inventories and all. Note that for weapon, it's 0 for none and 1 for available. So if you read 1, check the box and vice versa. This way the boxes are checked for weapons you already have. The same rule applies when writing: for a checked box you must save 1 to the corresponding value.

Oh well, that's it for now. I include the source code and the exe for this tutorial for you to look into.

- Fable Fox